{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
<input type="hidden" name='matchmaker_id' id='matchmaker_id' value="{$info.matchmaker_id}" />
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
				<!--form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">用户账号：</label>
						<div class="col-sm-9">
							<input hidden="text" value="{$info.u_id}" name="u_id" id="u_id"  />
							<input   value="{$info.member_name}" readonly class="form-control" id="top_member_name"/>
							<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.chooseMemberTop()">
								选择
							</button>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">红娘昵称：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="name"   name="name" value="{$info.name}" name="name" class="form-control" placeholder="请输入红娘昵称"  >
						</div>
					</div>

					<!--lwx 从业经验 -->
					<div class="form-group">
						<label class="col-sm-2 control-label">电话：</label>
						<div class="col-sm-9">
							<input type="number" autocomplete="off"    value="{$info.phone}" id="phone" name="phone" class="form-control"
								   placeholder="请输入电话">
						</div>
					</div>
					<!--lwx 从业经验 -->
					<div class="form-group">
						<label class="col-sm-2 control-label">从业经验：</label>
						<div class="col-sm-9">
							<input type="number" autocomplete="off"  value="{$info.work_years}"id="work_years" name="work_years" class="form-control"
								   placeholder="请输入从业经验">
						</div>
					</div>

					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">红娘等级：</label>
						<div class="col-sm-9">
							<select name="level_id" id="level_id" class="province-selector">
								<option value="">选择红娘等级</option>
								{foreach $level_rows as $key=>$vo }
								<option value="{$vo['id']}" {if condition="$info.level_id eq $vo['id']"}selected{/if}>{$vo['name']}</option>
								{/foreach}
							</select>
						</div>
					</div>
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">红娘性质：</label>
						<div class="col-sm-9">
							<select name="nature" id="nature" class="province-selector">
								<option value="1" {if condition="$info.nature eq 1"}selected{/if}>个人</option>
								<option value="2" {if condition="$info.nature eq 2"}selected{/if}>机构</option>
								<option value="3" {if condition="$info.nature eq 3"}selected{/if}>其他</option>

							</select>
						</div>
					</div>


					<div class="form-group">
						<label class="col-sm-2 control-label">上级推荐人：</label>
						<div class="col-sm-9">
							<input hidden="hidden" value="{$info.top_matchmaker_id}" name="top_matchmaker_id" id="top_matchmaker_id" value=""/>
							<input name="top_matchmaker_name" value="{$info.top_matchmaker_name}" readonly class="form-control" id="top_matchmaker_name"
								   value=""/>
							<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.chooseTop()">
								选择
							</button>
						</div>
					</div>

					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">年龄：</label>
						<div class="col-sm-9">
							<div class="layui-input-inline" style="width: 160px;">
								<select id="age" name="age" class="province-selector">
									<option value="">选择年龄</option>
									{for start="20" end="81" }
									<option value="{$i}" {if condition="$info.age eq $i"}selected{/if}>{$i}岁</option>
									{/for}
								</select>
							</div>
						</div>
					</div>

					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">性别：</label>
						<div class="col-sm-9">
							<select name="sex" id="sex" class="province-selector">
								<option value="2" {if condition="$info.sex eq 2"}selected{/if}>女</option>
								<option value="1" {if condition="$info.sex eq 1"}selected{/if}>男</option>
							</select>
						</div>
					</div>


					<div class="form-group">
						<label class="col-sm-2 control-label">生活照：</label>
						<div class="col-sm-6">
							<div class="images pic_list">
								<li id="images_upload"></li>
							</div>
							<div style="clear:both"></div>
							<span class="help-block m-b-none images_process"></span>
						</div>
					</div>


					<div class="form-group">
						<label class="col-sm-2 control-label">红娘寄语视频：</label>
						<div class="col-sm-6">
							<li id="videos_upload"></li>
							<div class="videos pic_list">
							</div>
							<div style="clear:both"></div>
							<span class="help-block m-b-none videos_process"></span>
						</div>
					</div>

					<!--share_videos-->
					<div class="form-group">
						<label class="col-sm-2 control-label">红娘分享视频：</label>
						<div class="col-sm-6">
							<li id="videos_upload2"></li>
							<div class="fxvideos pic_list">
							</div>
							<div style="clear:both"></div>
							<span class="help-block m-b-none videos_process"></span>
						</div>
					</div>
					<!--hand_success_videos-->
					<div class="form-group">
						<label class="col-sm-2 control-label">成功案例视频：</label>
						<div class="col-sm-6">
							<li id="videos_upload3"></li>
							<div class="cgvideos pic_list">
							</div>
							<div style="clear:both"></div>
							<span class="help-block m-b-none videos_process"></span>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">红娘寄语：</label>
						<div class="col-sm-9">
                            <textarea id="send_word" name="send_word" class="form-control"
									  placeholder="请输入红娘寄语">{$info.send_word}</textarea>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">下级佳人数：</label>
						<div class="col-sm-9">
							<input type="number" autocomplete="off" value="{$info.lower_matchmaker_num}"  id="lower_matchmaker_num" name="lower_matchmaker_num"
								   class="form-control"
								   placeholder="请输入下级佳人数">
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">牵手成功数量：</label>
						<div class="col-sm-9">
							<input type="number" autocomplete="off" value="{$info.hand_success_num}"  id="hand_success_num" name="hand_success_num"
								   class="form-control"
								   placeholder="请输入牵手成功数量">
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">牵手成功案例图片：</label>
						<div class="col-sm-6">
							<div class="hand_success_picture pic_list">
								<li id="hand_success_picture_upload"></li>
							</div>
							<div style="clear:both"></div>
							<span class="help-block m-b-none hand_success_picture_process"></span>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">牵线成功案例详情：</label>
						<div class="col-sm-9">
                            <textarea id="hand_success_desc" name="hand_success_desc"  class="form-control"
									  placeholder="请输入牵线成功案例详情">{$info.hand_success_desc}</textarea>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">男方概况：</label>
						<div class="col-sm-9">
                            <textarea id="boy_desc" name="boy_desc" class="form-control"
									  placeholder="请输入男方概况">{$info.boy_desc}</textarea>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">女方概况：</label>
						<div class="col-sm-9">
                            <textarea id="girl_desc" name="girl_desc" class="form-control"
									  placeholder="请输入女方概况">{$info.girl_desc}</textarea>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">身份证号：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" value="{$info.id_number}" id="id_number" name="id_number" class="form-control"
								   placeholder="请输入身份证号">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">微信号：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off"  value="{$info.wechat_number}" id="wechat_number" name="wechat_number"
								   class="form-control" placeholder="请输入微信号">
						</div>
					</div>

					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">市区：</label>
						<div class="col-sm-9">
							<div class="layui-form-item" id="area-picker">
								<div class="layui-input-inline" style="width: 160px;">
									<select id="province" name="province" class="province-selector">
										<option value="">--选择省--</option>
									</select>
								</div>
								<div class="layui-input-inline" style="width: 160px;">
									<select id="city" name="city" class="city-selector">
										<option value="">--选择市--</option>
									</select>
								</div>
								<div class="layui-input-inline" style="width: 160px;">
									<select id="county" name="county" class="county-selector">
										<option value="">--选择区--</option>
									</select>
								</div>
							</div>
						</div>
					</div>


					<div class="form-group">
						<label class="col-sm-2 control-label">详细地址：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="address"  value="{$info.address}" name="address" class="form-control"
								   placeholder="请输入详细地址">
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">服务区域：</label>
						<div class="col-sm-9">
                            <textarea id="service_zone" name="service_zone"  class="form-control"
									  placeholder="请输入服务区域">{$info.service_zone}</textarea>
						</div>
					</div>



					<div class="form-group">
						<label class="col-sm-2 control-label">简介：</label>
						<div class="col-sm-9">
                            <textarea id="remarks" name="remarks"  class="form-control"
									  placeholder="请输入简介">{$info.remarks}</textarea>
						</div>
					</div>


					<!--总结文字  -->
					<div class="form-group">
						<label class="col-sm-2 control-label">总结文字：</label>
						<div class="col-sm-9">
                            <textarea id="summarize_txt" name="summarize_txt" class="form-control"
									  placeholder="请输入总结文字"> {$info.summarize_txt}</textarea>
						</div>
					</div>
					<!--总结视频  -->
					<div class="form-group">
						<label class="col-sm-2 control-label">总结视频：</label>
						<div class="col-sm-6">
							<li id="videos_upload4"></li>
							<div class="zjvideos pic_list">
							</div>
							<div style="clear:both"></div>
							<span class="help-block m-b-none videos_process"></span>
						</div>
					</div>

					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">是否显示在首页：</label>
						<div class="col-sm-9">
							<input name="show_home" value="1" type="radio" {if condition="$info.show_home eq '1'"}checked{/if} title="显示">
							<input name="show_home" value="0" type="radio" {if condition="$info.show_home eq '0'"}checked{/if} title="不显示">
						</div>
					</div>

					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">状态：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['status'])){ $info['status'] = '0'; }; ?>
							<input name="status" value="1" type="radio" {if condition="$info.status eq '1'"}checked{/if} title="通过">
							<input name="status" value="0" type="radio" {if condition="$info.status eq '0'"}checked{/if} title="待审核">
							<input name="status" value="2" type="radio" {if condition="$info.status eq '2'"}checked{/if} title="拒绝">
						</div>
					</div>

				<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.update()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js?v=1115" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script>
	layui.config({
		base: '../../static/js/plugins/layui/mods/',//相对路径
		version: '1.0'
	});
	layui.use(['form', 'layarea'], function () {
		var layarea = layui.layarea;
		let obj1 = layarea.render({
			elem: '#area-picker',
			data: {
				'province':'{$info.province}',
				'city':'{$info.city}',
				'county':'{$info.county}'
			},
			change: function (res) {
				//选择结果
				console.log(res);
			}
		});
	});

laydate.render({elem: '#createtime',type: 'datetime',trigger:'click'});
laydate.render({elem: '#expiretime',type: 'datetime',trigger:'click'});

	uploader('images_upload', 'images', 'image', true, '{$info.pictures}', '{:getUploadServerUrl()}');
	setUploadButton('images_upload');

	uploader('videos_upload', 'videos', 'video', true, '{$info.videos}', '{:getUploadServerUrl()}');
	uploader('videos_upload2', 'fxvideos', 'video', true, '{$info.share_videos}', '{:getUploadServerUrl()}');
	uploader('videos_upload3', 'cgvideos', 'video', true, '{$info.hand_success_videos}', '{:getUploadServerUrl()}');
	uploader('videos_upload4', 'zjvideos', 'video', true, '{$info.summarize_videos}', '{:getUploadServerUrl()}');

	uploader('hand_success_picture_upload', 'hand_success_picture', 'image', true, '{$info.hand_success_picture}', '{:getUploadServerUrl()}');
	setUploadButton('hand_success_picture_upload');


var CodeInfoDlg = {
	CodeInfoData: {},
	validateFields: {}
}

CodeInfoDlg.collectData = function () {
	this.set('name').set('phone').set('sex').set('work_years').set('level_id').set('top_matchmaker_id').set('age')
			.set('send_word').set('summarize_txt').set('hand_success_desc').set('id_number').set('wechat_number').set('u_id')
			.set('province').set('city').set('county').set('address').set('service_zone').set('remarks')
			.set('hand_success_num').set('lower_matchmaker_num').set('matchmaker_id').set('boy_desc').set('girl_desc').set('name').set('nature');
};

	CodeInfoDlg.chooseTop = function () {
		var index = layer.open({
			type: 2,
			title: '选择上级推荐人',
			area: ['800px', '100%'],
			fix: false,
			maxmin: true,
			content: Feng.ctxPath + '/ZhAuthentication/selectList'
		});
		if (!IsPC()) {
			layer.full(index)
		}
	}

	// 获取上级推荐人
	function GetTopValue(value) {
		let name = value.nickname + " "+ value.phone;
		$('#top_matchmaker_name').val(name)
		$('#top_matchmaker_id').val(value.matchmaker_id)
		console.log('获取上级推荐人', value)
	}

	    //选择用户账号
    CodeInfoDlg.chooseMemberTop = function () {
        var index = layer.open({
            type: 2,
            title: '选择用户账号',
            area: ['800px', '100%'],
            fix: false,
            maxmin: true,
            content: Feng.ctxPath + '/ZhMatchmaker/selectMember'
        });
        if (!IsPC()) {
            layer.full(index)
        }
    }

    // 获取关联的用户
    function GetMemberTopValue(value) {
    	let name = "";
    	if(value.nickname != null){
    		name = value.nickname;
    	}
        name += " "+ value.phone;
        $('#top_member_name').val(name)
        $('#u_id').val(value.uid)
    }

CodeInfoDlg.update = function () {
	 this.clearData();
	 this.collectData();
	 if (!this.validate()) {
	 	return;
	 }
	var images = [];
	$(".images li").each(function () {
		if ($(this).find('img').attr('src')) {
			images.push($(this).find('img').attr('src'));
		}
	});
	var videos = [];
	$(".videos li").each(function () {
		if ($(this).find('i')) {
			videos.push($(this).find('i').text())
		}
	});

	//分享视频
	var share_videos = [];
	$(".fxvideos li").each(function () {
		if ($(this).find('i')) {
			share_videos.push($(this).find('i').text())
		}
	});

	//牵手成功hand_success_videos
	var hand_success_videos = [];
	$(".cgvideos li").each(function () {
		if ($(this).find('i')) {
			hand_success_videos.push($(this).find('i').text())
		}
	});
	//总结视频
	var summarize_videos = [];
	$(".zjvideos li").each(function () {
		if ($(this).find('i')) {
			summarize_videos.push($(this).find('i').text())
		}
	});

	var hand_success_picture = [];
	$(".hand_success_picture li").each(function () {
		if ($(this).find('img').attr('src')) {
			hand_success_picture.push($(this).find('img').attr('src'));
		}
	});

	 var status = $("input[name = 'status']:checked").val();
	var show_home = $("input[name = 'show_home']:checked").val();
	 var ajax = new $ax(Feng.ctxPath + "/ZhMatchmaker/update", function (data) {
	 	if ('00' === data.status) {
	 		Feng.success(data.msg,1000);
	 		window.parent.CodeGoods.table.refresh();
	 		CodeInfoDlg.close();
	 	} else {
	 		Feng.error(data.msg + "！",1000);
		 }
	 })
	ajax.set('show_home', show_home);
	ajax.set('status', status);
	ajax.set('pictures', JSON.stringify(images));
	ajax.set('videos', JSON.stringify(videos));
	ajax.set('hand_success_videos', JSON.stringify(hand_success_videos));
	ajax.set('share_videos', JSON.stringify(share_videos));
	ajax.set('summarize_videos', JSON.stringify(summarize_videos));
	ajax.set('hand_success_picture', JSON.stringify(hand_success_picture));
	 ajax.set(this.CodeInfoData);
	 ajax.start();
};


</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
